package com.zjmzxfzhl.modules.purchase.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zjmzxfzhl.common.base.BaseService;
import com.zjmzxfzhl.modules.purchase.controller.dto.PurchaseContractDto;
import com.zjmzxfzhl.modules.purchase.controller.dto.PurchaseContractQueryDto;
import com.zjmzxfzhl.modules.purchase.controller.vo.PurchaseContractDetailVo;
import com.zjmzxfzhl.modules.purchase.controller.vo.PurchaseContractVo;
import com.zjmzxfzhl.modules.purchase.controller.vo.PurchaseIndentSimpleVo;
import com.zjmzxfzhl.modules.purchase.controller.vo.PurchaseIndentVo;
import com.zjmzxfzhl.modules.purchase.entity.PurchaseContract;
import com.zjmzxfzhl.modules.purchase.entity.PurchasePayment;

import java.io.File;
import java.util.List;

/**
 * Service
 *
 * @author 庄金明
 */
public interface PurchaseContractService extends BaseService<PurchaseContract> {
    /**
     * 分页查询
     *
     * @param page
     * @param purchaseContract
     * @return
     */
    IPage<PurchaseContractVo> list(IPage<PurchaseContractVo> page, PurchaseContractQueryDto purchaseContract);

    /**
     * 采购订单默认生成合同，并返回需要任何合并的订单列表
     *
     * @return
     */
    List<PurchaseIndentVo> genContract();

    /**
     * 查询指定审批单下可合并的订单
     * @param orderId
     * @param supplierId
     * @return
     */
    List<PurchaseIndentVo> findGenIndent(Long orderId, Long supplierId);

    /**
     * 删除合同
     *
     * @param ids
     */
    void deleteContracts(List<Long> ids);

    /**
     * 合并生成合同
     *
     * @param contractCode
     * @param comment
     * @param indentIds
     */
    void mergeIndent(String contractCode, String comment, List<Long> indentIds);

    /**
     * 跟新合同
     *
     * @param contractDto
     */
    void updateContract(PurchaseContractDto contractDto);

    /**
     * 获取合同详情
     *
     * @param contractId
     * @return
     */
    PurchaseContractDetailVo getContractDetail(Long contractId);

    /**
     * 临时批量处理新增字段payment的初始化
     */
    void initAllPayAmount();

    /**
     * 临时批量处理新增字段payment的初始化
     * @param payment
     */
    void initPayAmount(PurchasePayment payment);


    /**
     * 获取数据库中合同（不存在则新增）
     * @param contract
     * @return
     */
    PurchaseContract validPurchaseContract(PurchaseContract contract);

    /**
     * 导出付款审批单
     *
     * @param contractId
     * @param paymentId
     * @return
     */
    File exportPayment(Long contractId, Long paymentId, Boolean exWithInvoice);

    /**
     * 查询付款情况
     *
     * @param contractId
     * @return
     */
    List<PurchasePayment> queryPayments(Long contractId);

    /**
     * 导出采购订单
     *
     * @param contractId
     * @param indentId
     * @return
     */
    File exportIndent(Long contractId, Long indentId);

    /**
     * 查询订单
     *
     * @param contractId
     * @return
     */
    List<PurchaseIndentSimpleVo> queryIndents(Long contractId);
}
